package com.lottery.im.module.result.adapter.result.item;

import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import java.util.List;

public class HorizontalLottery30Adapter extends BaseQuickAdapter<String, BaseViewHolder> {
  public HorizontalLottery30Adapter(@Nullable List<String> data) {
    super(R.layout.item_horizontal_lottery30_list, data);
  }

  @Override protected void convert(BaseViewHolder helper, String item) {
    helper.setText(R.id.tv_num, item);
    if ("0".equals(item)) {
      helper.getView(R.id.tv_num).setBackgroundResource(R.drawable.lottery_ball_10);
    } else {
      helper.getView(R.id.tv_num).setBackgroundResource(getResourceId("lottery_ball_0" + item));
    }
  }

  //根据图片名称取得对应图片
  public int getResourceId(String name) {
    int resId = mContext.getResources().getIdentifier(name, "drawable", mContext.getPackageName());
    //解析资源文件夹下，id为resId的图片
    return resId;
  }
}